﻿using MiData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VolunteerManager.Model
{
    /// <summary>
    /// 志愿者
    /// </summary>
    public class Voluteer : MiActiveRecord
    {
        /// <summary>
        /// 复制对象
        /// </summary>
        /// <returns></returns>
        public Voluteer Clone()
        {
            return new Voluteer()
            {
                Name = this.Name,
                Birth = this.Birth,
                Desc = this.Desc,
                Email = this.Email,
                Forte = this.Forte,
                JoinDate = this.JoinDate,
                Peoples = this.Peoples,
                QQ = this.QQ,
                Sex = this.Sex,
                Phone = this.Phone,
                Photo = this.Photo,
                Wechat = this.Wechat,
                Professional = this.Professional,
                Models = this.Models,
                Vocation = this.Vocation
            };
        }
        
        /// <summary>
        /// 回滚对象
        /// </summary>
        /// <param name="v"></param>
        public void RollBack(Voluteer v)
        {
            this.Name = v.Name;
            this.Birth = v.Birth;
            this.Desc = v.Desc;
            this.Email = v.Email;
            this.Forte = v.Forte;
            this.JoinDate = v.JoinDate;
            this.Peoples = v.Peoples;
            this.QQ = v.QQ;
            this.Sex = v.Sex;
            this.Phone = v.Phone;
            this.Photo = v.Photo;
            this.Wechat = v.Wechat;
            this.Professional = v.Professional;
            this.Models = v.Models;
            this.Vocation = v.Vocation;
        }

        [Column(Name = "Name")]
        public string Name { get; set; }


        [Column(Name = "Wechat")]
        public string Wechat { get; set; }

        [Column(Name = "Sex")]
        public Sex Sex { get; set; }

        /// <summary>
        /// 民族
        /// </summary>
        [Column(Name = "Peoples")]
        public Man Peoples { get; set; }

        /// <summary>
        /// 籍贯
        /// </summary>
        [Column(Name = "Regions")]
        public string Regions { get; set; }

        [Column(Name = "Birth")]
        public DateTime Birth { get; set; }


        [Column(Name = "Phone")]
        public string Phone { get; set; }


        [Column(Name = "Email")]
        public string Email { get; set; }

        [Column(Name = "QQ")]
        public string QQ { get; set; }

        [Column(Name = "JoinDate")]
        public DateTime JoinDate { get; set; }

        /// <summary>
        /// 技能、特长
        /// </summary>
        [Column(Name = "Forte")]
        public string Forte { get; set; }

        [Column(Name = "Photo")]
        public string Photo { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [Column(Name = "Desc")]
        public string Desc { get; set; }

        /// <summary>
        /// 工作行业
        /// </summary>
        [Column(Name = "Professional")]
        public string Professional { get; set; }

        /// <summary>
        /// 活动模式
        /// </summary>
        [Column(Name = "Models")]
        public string Models { get; set; }

        /// <summary>
        /// 职业
        /// </summary>
        [Column(Name = "Vocation")]
        public string Vocation { get; set; }

        /// <summary>
        /// 搜索内容
        /// </summary>
        [Column(Name = "SearchWord")]
        public string SearchWord { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [Column(Name = "GroupID")]
        public int GroupID { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [Column(Name = "GroupName")]
        public string GroupName { get; set; }

        private Group _g;
        /// <summary>
        /// 组对象
        /// </summary>
        public Group Group
        {
            get
            {
                return _g;
            }
            set
            {
                this.GroupID = value.ID;
                this.GroupName = value.Name;
                _g = value;
            }
        }

        public Voluteer()
        {
            this.Photo = "";
            this.JoinDate = DateTime.Now;
            this.GroupID = 1;
            this.Birth = new DateTime(1982, 10, 1);
        }

        public override long Save()
        {
            SearchWord = Name + "|" + Wechat;

            return base.Save();
        }

        public override string TableName
        {
            get { return "Voluteer"; }

        }

        public void DoRaisePropertyChanged()
        {
            this.RaisePropertyChanged("Name");
            this.RaisePropertyChanged("Wechat");
            this.RaisePropertyChanged("QQ");
            this.RaisePropertyChanged("Peoples");
            this.RaisePropertyChanged("Sex");
            this.RaisePropertyChanged("JoinDate");
            this.RaisePropertyChanged("Birth");
            this.RaisePropertyChanged("Professional");
            this.RaisePropertyChanged("Group");
        }
    }
}
